<?php
	namespace Common\Logic;
	use Common\Model\GoodsBrandModel;
	class GoodsBrandLogic extends GoodsBrandModel{
		/*
		* Function:		getGoodsBrandList
		* Description:	商品品牌列表
		* @param:		$page string 起始页
						$filter array 过滤数组
						$pageSize string 每页显示条数
		*/
		public function getGoodsBrandList($page=1,$filter = '',$pageSize=20){
			$conditon = $this->getGoodsBrandFilter($filter);
			return $this->where($conditon)->order('id desc')->limit(($page-1)*$pageSize,$pageSize)->select();
		}
		
		/*
		* Function:get:	getGoodsBrandFilter
		* Description:	商品品牌列表搜索过滤项
		* @param:		$filter array 过滤数组
		*/
		public function getGoodsBrandFilter($filter = ''){
			$conditon = array();
			if(!empty($filter['brand_name'])){
				$conditon['brand_name'] = array('like','%'.$filter['brand_name'].'%');
			}
			return $conditon;
		}
		
		/*
		* Function:get:	getGoodsBrandCount
		* Description:	商品品牌列表总数
		* @param:		$filter array 过滤数组
		*/
		public function getGoodsBrandCount($filter = ''){
			$conditon = $this->getGoodsBrandFilter($filter);
			return $this->where($conditon)->count();
		}
		
		/*
		* Function:		addGoodsBrand
		* Description:	增加商品品牌
		* @param:		$data array 增加的数组
		*/
		public function addGoodsBrand($data){
			return $this->add($data);
		}
		
		/*
		* Function:		getGoodsBrandInfo
		* Description:	获取商品品牌信息 by row
		* @param:		$id int ID
		*/
		public function getGoodsBrandInfo($id){
			return $this->where(array('id'=>$id))->find();
		}
		
		/*
		* Function:		updateGoodsBrand
		* Description:	更新商品品牌
		* @param:		$data array 更新的数组
		*/
		public function updateGoodsBrand($data){
			return $this->save($data);
		}
		
		/*
		* Function:		deleteGoodsBrand
		* Description:	删除商品品牌
		* @param:		$id int ID
		*/
		public function deleteGoodsBrand($id){
			return $this->where(array('id'=>$id))->delete();
		}
		
		/*
		* Function:		getGoodsBrandAllList
		* Description:	部门列表
		*/
		public function getGoodsBrandAllList(){
			return $this->where(array('status'=>1))->select();
		}
	}
?>